﻿<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <meta name="description" content="新疆大学 监考报名" />
    <meta name="author" content="" />
    <link rel="shortcut icon" href="images/shortcut.ico">
    <title>确认</title>
    <link rel="stylesheet" href="css/css.css">
    <link rel="stylesheet" href="css/fonts/linecons/css/linecons.css">
    <link rel="stylesheet" href="css/fonts/fontawesome/css/font-awesome.min.css">
    <link rel="stylesheet" href="css/bootstrap.css">
    <link rel="stylesheet" href="css/xenon-core.css">
    <link rel="stylesheet" href="css/xenon-forms.css">
    <link rel="stylesheet" href="css/xenon-components.css">
    <link rel="stylesheet" href="css/xenon-skins.css">
    <link rel="stylesheet" href="css/custom.css">
    <script src="js/jquery-1.11.1.min.js"></script>
    <script src="js/cookie.js"></script>
    <script src="js/ready.js"></script>
    <script src="js/myjs.js"></script>
    <style type="text/css">
    #userinfor {
        font-size: 16px;
        font-family: "微软雅黑";
    }
    
    #userinfor a {
        text-decoration: none;
    }
    </style>
    <!-- HTML5 shim and Respond.js IE8 support of HTML5 elements and media queries -->
    <!--[if lt IE 9]>
        <script src="js/html5shiv.min.js"></script>
        <script src="js/respond.min.js"></script>
    <![endif]-->
    <script type="text/javascript">
    var tempath;
    var authority;
    var austr;
    var pagef;
    $(document).ready(function() {
        islogin(1);
        //解析浏览器地址栏
        var path = window.location.href;
        var patt = new RegExp("=");
        if (patt.test(path)) {
            server_path = path;
            var index_path = path.indexOf("=");
            var authority_path = path.indexOf("&");
            path = path.substring(index_path + 1, authority_path);
            tempath = path;
            authority = server_path.lastIndexOf("=");
            authority = server_path.substring(authority + 1).substring(0, 1);
            if (authority == '1') {
                austr = "registlist";
                $('#tunit').hide();
                $("#userinfor").css("display","none");
            } else {
                autoajax('tunit', autoajaxfunc);
                austr = "secondregistlist";
            }
        } else {
            alert('请先选择考试科目，再查看报名列表');
            /*window.location.href="select.html";*/
        }
        var loginuser;
        $.ajax({
            type: "get",
            url: "Login",
            timeout: 2000,
            cache: false,
            data: {
                action: 'Uid'
            },
            beforeSend: function(XMLHttpRequest) {

            },
            success: function(data, textStatus) {
                if (data != '') {
                    var user = getCookieValue("username");
                    $('#username').html(user);
                    loginuser = user;
                }
            },
            complete: function(XMLHttpRequest, textStatus) {

            },
            error: function() {
                alert("请求失败！");
            }
        });

        autoajax('tno', autoajaxfunc);
        autoajax('tname', autoajaxfunc);
        autoajax('tstudy', autoajaxfunc);
        autoajax('texam', autoajaxfunc);
        autoajax('tstate', autoajaxfunc);


        $('#logout').click(function() {
           exit();
        });
        $('#btnagree').on('click',function() {
        	if(!confirm("确认同意?"))
        		return;
            $.ajax({
            url: 'Search?action=agreeSearch&username='+getCookieValue("username"),
            data: {
                'sc': JSON.stringify(jdata()),
                'page': 0,
                'count': 0,
                'isAgree':1
            },
            method: 'POST',
            success: function(res) {
            	pagef();
                alert(res);
            }
        });
        });
        pagef = autoajaxfunc();
    });

		function t(a, b, c) {
            this.pname = a;
            this.v = b;
            this.compare = c;
        };

        function jdata() {
            var sc = new Array();
            ~(function statetransfer(v, arr) {
                if (v < 3) {
                    arr.push(new t('signstate', v, 1));
                } else {
                    arr.push(new t('signstate', 0, 1));
                    arr.push(new t('schoolstate', v % 10, 1));
                }
            })($('#tstate').val(), sc);

            sc.push(new t('teano', $('#tno').val()));
            sc.push(new t('teaname', $('#tname').val()));
            sc.push(new t('subordunit', $('#tunit').val()));
            sc.push(new t('isstudy', $('#tstudy').val(),1));
            sc.push(new t('exampass', $('#texam').val(),1));
            sc.push(new t('sub_no',tempath , 1));
            return sc;
        };

    function autoajaxfunc() {
        
        return page($('#pagenumber'), 10, 'Search?action=agreeSearch&username='+getCookieValue("username"), jdata, dataadd);
    }

    function dataadd(data) {
        var item = jQuery.parseJSON(data);
        if (item.teano == '0') {
            $("#main-table").find("tbody").html('');
            alert('没有匹配的人员信息');
        } else {
            $("#main-table").find("tbody").html('');
            for (var i = 0; i < item.length; i++) {
                $('#exam').html(item[0].sub_name);
                add(item[i].teaname, item[i].teano, item[i].subordunit, item[i].signstate, item[i].schoolstate,item[i].isstudy,item[i].exampass);
            }
            location.hash = "#example-2_wrapper";
        }
    }

    function add(name, no, location, signstate, schoolstate,study,exam) {
        var n = $("#main-table").find("tbody").find("tr").length % 2;
        var str = $("<tr role=\"row\" class=\"\"><td>mhk</td><td>1002</td><td>1002</td><td></td><td></td><td><a href=\"javascript:void(0);\" onclick=\"regedit('" + no + "');\" class=\"btn btn-secondary btn-sm btn-icon icon-left\">" +
            "同意</a><a href=\"javascript:void(0);\" onclick=\"refuse('" + no + "');\" class=\"btn btn-danger btn-sm btn-icon icon-left\">" +
            "拒绝</a></td></tr>");
        if (n == 0) {
            str.addClass("odd");
        } else {
            str.addClass("even");
        }
        var t = str.find("td");
        $(t[0]).html(name);
        $(t[1]).html(no);
        $(t[2]).html(location);
		$(t[3]).html(study==1?'已完成学习':'未完成学习');
		$(t[4]).html(exam==1?'已完成考试':'未完成考试');
		
        var strstate = '';
        var ishtml = true;
        if (authority == 1) {
             	 if(signstate==2){
		                      strstate += '教务办驳回请求';
		                       ishtml=false;
		                  }
		                  else
		            if (signstate == 0) {
		                {
		                  	//strstate += '教务办审核通过';
		                    if (schoolstate == 0){
			                    strstate = '教务办审核通过，教务处审核通过';
	             		     }
	             		     else
				                if (schoolstate == 1){
				                    strstate += '教务办审核通过，教务处审核中';
				                }
			                 else{
			                    strstate += '，教务处驳回请求';
			                 }
		                   ishtml=false;
		               }
               
               }
                    
        } else if (authority == 2) {
            if (signstate == 1) {
                //strstate="<tr><td><a href=\"javascript:void(0);\" onclick=\"advanceAgree('"+no+"')\"></a></td></tr>";   
                strstate+="教务办审核中"+"&nbsp;&nbsp;&nbsp;&nbsp;"+"<a href=\"javascript:void(0);\" onclick=\AdvanceAgree('"+no+"');\ class=\"btn btn-danger btn-sm btn-icon icon-left\";>同意</a>";
                 ishtml=false;
            }
                    else
		                 if(signstate==0){
			                  if(schoolstate==1){
			                    ishtml=true;
			                  }
			                  else
			                     if(schoolstate==0){
			                          strstate += '教务办审核通过，教务处审核通过';
			                         ishtml=false;
			                     }
			                     else{
			                           strstate += '教务办审核通过，教务处驳回请求';
			                           ishtml=false;
			                     }
		                 }
		                 else{
		                     	strstate +="<a href=\"javascript:void(0);\" onclick=\againagree('"+no+"');\ class=\"btn btn-danger btn-sm btn-icon icon-left\";>教务办驳回请求</a>";
				                ishtml=false;
		                 }
		                       
					        
			        
               }
     
         if (!ishtml) {
	     t.last().html(strstate).css("color","green");
		       }
        $("#main-table").find("tbody").append(str);
    }
    
    var AdvanceAgree=function(no){
          var result=confirm("确认跨级审核通过该教师的报名信息吗？");
          if(result){
              $.ajax({
                 url:"Login",
                 type:"post",
                 dataType:"json",
                 data:{
                  action:"SuperAgree",
                  teano:no,
                  subno:tempath
                 },
                 success:function(data){
                  if(data=="1"){
                     window.location.reload();
                  }
                 }
              });
          }
    };
   function againagree(no){
   		   if(confirm("您确定同意该教师的报名申请吗？")){
   		      $.ajax({
   		      url:"Subject",
   		      type:"post",
   		      data:{
   		        	action: 'sureagain',
                    subno: tempath,
                    teano: no
   		      },
   		      success:function(data){
   		        	var json=jQuery.parseJSON(data);
   		        	if(json.id==0){
   		        	  alert("操作成功");
   		        	  window.location.reload();
   		        	}
   		      }
   		      });
   		   }
   }
    function regedit(item) {
        //获取权限
        //教务办审核人员信息
        if (authority == 1) {
          
            var t = $(event.srcElement).parent();
            $.ajax({
                type: 'post',
                url: 'Subject',
                data: {
                    action: 'sureregist',
                    subno: tempath,
                    teano: item
                },
                success: function(data, textStatus) {
                    var json = jQuery.parseJSON(data);
                    if (json.id == 0) {
                        //t.html('审核通过').css('color', 'green');
                        window.location.reload();
                    }
                }

            });
        } else
        //教务处审核人员信息
        if (authority == 2) {
            var t = $(event.srcElement).parent();
            $.ajax({
                type: 'post',
                url: 'Subject',
                data: {
                    action: 'secondsure',
                    subno: tempath,
                    teano: item
                },
                success: function(data, textStatus) {
                    var json = jQuery.parseJSON(data);
                               if (json.id == 0) {
                            window.location.reload();
                  }
              }
            });

        }
    }

    function refuse(no) {
        if(confirm("确认拒绝改教师的报名申请吗？")){
          $.ajax({
            url: "Login",
            type: "post",
            data: {
                action: "firstrefuse",
                teano: no,
                subno: tempath,
                authority: authority
            },
            success: function(data) {
                var json = jQuery.parseJSON(data);
                if (json.id > 0) {
                    window.location.reload();
                }
            }
        });
        }
       

        /* var item=$(event.srcElement).parents("tr");
              $(item.find("a").first()).attr("onclick","");
              var result=$(item.find("a").first()).html("报名已被拒绝");    */
        /* $.ajax({
          url:'Subject',
          type:'post',
          data:{
          action:"deleteRegist",
          subno:tempath,
          teano:no
          },
          success:function(data,textStatus){
            var json=jQuery.parseJSON(data);
            if(json.id==0){
              window.location.reload();
            }
          }
         });*/


    }
    	 window.onunload = function() {   
               exit();
		};  
    </script>
</head>

<body class="page-body">
    <div class="settings-pane">
        <a href="#" data-toggle="settings-pane" data-animate="true">&times;
        </a>
        <div class="settings-pane-inner">
            <div class="row">
                <div class="col-md-4">
                    <div class="user-info">
                        <div class="user-image">
                            <a href="extra-profile.html">
                                <img src="images/user-2.png" class="img-responsive img-circle" />
                            </a>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
    <div class="page-container">
        <!-- add class "sidebar-collapsed" to close sidebar by default, "chat-visible" to make chat appear always -->
        <!-- Add "fixed" class to make the sidebar fixed always to the browser viewport. -->
        <!-- Adding class "toggle-others" will keep only one menu item open at a time. -->
        <!-- Adding class "collapsed" collapse sidebar root elements and show only icons. -->
        <div class="sidebar-menu toggle-others fixed">
            <div class="sidebar-menu-inner">
                <header class="logo-env">
                    <!-- logo -->
                    <div class="logo">
                        <a href="dashboard-1.html" class="logo-expanded">
                            <img src="images/logo.png" width="80" alt="" />
                        </a>
                        <a href="dashboard-1.html" class="logo-collapsed">
                            <img src="images/logo.png" width="40" alt="" />
                        </a>
                    </div>
                    <!-- This will toggle the mobile menu and will be visible only on mobile devices -->
                    <div class="mobile-menu-toggle visible-xs">
                        <a href="#" data-toggle="user-info-menu">
                            <i class="fa-bell-o"></i>
                            <span class="badge badge-success">7</span>
                        </a>
                        <a href="#" data-toggle="mobile-menu">
                            <i class="fa-bars"></i>
                        </a>
                    </div>
                </header>
                <ul id="main-menu" class="main-menu">
                    <!-- add class "multiple-expanded" to allow multiple submenus to open -->
                    <!-- class "auto-inherit-active-class" will automatically add "active" class for parent elements who are marked already with class "active" -->
                    <li>
                        <a href="userinfo2.jsp">
                            <i class="linecons-cog"></i>
                            <span class="title">个人资料</span>
                        </a>
                    </li>
                    <li class="active opened active expanded has-sub">
                        <a href="agree.html">
                            <i class="linecons-desktop"></i>
                            <span class="title">审核</span>
                        </a>
                        <ul>
                            <li>
                                <a href="select.jsp">
                                    <span class="title">选择考试科目</span>
                                </a>
                            </li>
                        </ul>
                    </li>
                </ul>
            </div>
        </div>
        <div class="main-content">
            <!-- User Info, Notifications and Menu Bar -->
            <nav class="navbar user-info-navbar" role="navigation">
                <!-- Left links for user info navbar -->
                <ul class="user-info-menu left-links list-inline list-unstyled">
                    <li class="hidden-sm hidden-xs">
                        <a href="#" data-toggle="sidebar">
                            <i class="fa-bars"></i>
                        </a>
                    </li>
                    <li class="dropdown hover-line">
                        <a href="#" data-toggle="dropdown">
                            <i class="fa-envelope-o"></i>
                            <span class="badge badge-green">1</span>
                        </a>
                        <ul class="dropdown-menu messages">
                            <li>
                                <ul class="dropdown-menu-list list-unstyled ps-scrollbar">
                                    <li class="active">
                                        <!-- "active" class means message is unread -->
                                        <a href="#">
                                            <span class="line">
                                                <strong>使用帮助</strong>
                                            </span>
                                            <span class="line desc small">请仔细阅读，会对您有帮助的！
                                            </span>
                                        </a>
                                    </li>
                                </ul>
                            </li>
                            <li class="external">
                                <a href="blank-sidebar.html">
                                    <span>All Messages</span>
                                    <i class="fa-link-ext"></i>
                                </a>
                            </li>
                        </ul>
                    </li>
                </ul>
                <!-- Right links for user info navbar -->
                <ul class="user-info-menu right-links list-inline list-unstyled">
                    <li class="dropdown user-profile">
                        <a href="" data-toggle="dropdown">
                            <span id="username"></span>
                            <span>，欢迎您！
                            </span>
                        </a>
                    </li>
                    <li class="dropdown user-profile">
                        <a href="" data-toggle="dropdown" id="logout">
                            <span>退出登录
                            </span>
                        </a>
                    </li>
                </ul>
            </nav>
            <div class="panel panel-default">
                <div class="panel-heading">
                    <h3 class="panel-title"><span id="exam"></span>报名信息列表</h3> &nbsp;&nbsp;&nbsp;&nbsp;
                    <div style="float: right;">
                        <input type="button" value="全部同意" id="btnagree" class="btn btn-danger">
                    </div>
                    <div class="btn btn-danger" id="userinfor"><a href="javascript:void(0);" onclick="exportinfor()">导出报名信息</a></div>
                </div>
                <script type="text/javascript">
                //导出报名人员的信息
                function exportinfor() {
                        window.location.href = "Login?action=exportinfor&subno=" + tempath;
                }
                </script>
                <div class="panel-body">
                    <div id="example-2_wrapper" class="dataTables_wrapper form-inline dt-bootstrap no-footer">
                        <table class="table table-bordered table-striped dataTable no-footer" id="main-table" role="grid" aria-describedby="example-2_info">
                            <thead>
                                <tr role="row">
                                    <th rowspan="1" colspan="1" style="width: 15%;">教师姓名</th>
                                    <th rowspan="1" colspan="1" style="width: 15%;">教师工号</th>
                                    <th rowspan="1" colspan="1" style="width: 15%;">所在学院</th>
                                    <th rowspan="1" colspan="1" style="width: 15%;">学习进度</th>
                                    <th rowspan="1" colspan="1" style="width: 15%;">考试进度</th>
                                    <th rowspan="1" colspan="1" style="width: 15%;">意见</th>
                                </tr>
                                <tr role="row">
                                    <th>
                                        <input type="text" id="tname">
                                    </th>
                                    <th>
                                        <input type="text" id="tno">
                                    </th>
                                    <th>
                                        <input type="text" id="tunit">
                                    </th>
                                    <th>
                                        <select id="tstudy">
                                            <option value="" selected>全部</option>
                                            <option value="0">未完成学习</option>
                                            <option value="1">已完成学习</option>
                                        </select>
                                    </th>
                                    <th>
                                        <select id="texam">
                                            <option value="" selected>全部</option>
                                            <option value="0">未完成考试</option>
                                            <option value="1">已完成考试</option>
                                        </select>
                                    </th>
                                    <th>
                                        <select id="tstate">
                                            <option value="" selected>全部</option>
                                            <option value="0">教务办审核通过</option>
                                            <option value="1">教务办审核中</option>
                                            <option value="2">教务办已经拒绝</option>
                                            <option value="10">教务处审核通过</option>
                                            <option value="11">教务处审核中</option>
                                            <option value="12">教务处已经拒绝</option>
                                        </select>
                                    </th>
                                </tr>
                            </thead>
                            <tbody class="middle-align">
                            </tbody>
                        </table>
                        <div class="row">
                            <div class="col-xs-6">
                                <div class="dataTables_info" id="example-2_info" role="status" aria-live="polite"></div>
                            </div>
                            <div class="col-xs-6">
                                <div class="dataTables_paginate paging_simple_numbers" id="pagenumber">
                                    <ul class="pagination">
                                    </ul>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
            <!-- Main Footer -->
            <!-- Choose between footer styles: "footer-type-1" or "footer-type-2" -->
            <!-- Add class "sticky" to  always stick the footer to the end of page (if page contents is small) -->
            <!-- Or class "fixed" to  always fix the footer to the end of page -->
            <footer class="main-footer sticky footer-type-1">
                <div class="footer-inner">
                    <!-- Add your copyright text here -->
                    <div class="footer-text">
                        &copy; 2015
                        <strong>Backbone Studio</strong>
                    </div>
                    <!-- Go to Top Link, just add rel="go-top" to any link to add this functionality -->
                    <div class="go-up">
                        <a href="#" rel="go-top">
                            <i class="fa-angle-up"></i>
                        </a>
                    </div>
                </div>
            </footer>
        </div>
    </div>
    <div class="page-loading-overlay">
        <div class="loader-2"></div>
    </div>
    <!-- Bottom Scripts -->
    <script src="js/bootstrap.min.js"></script>
    <script src="js/TweenMax.min.js"></script>
    <script src="js/resizeable.js"></script>
    <script src="js/xenon-toggles.js"></script>
    <!-- JavaScripts initializations and stuff -->
    <script src="js/xenon-custom.js"></script>
</body>

</html>
